qrisp.QuantumCircuit.transpile#

QuantumCircuit.transpile(transpilation_level=inf, **qiskit_kwargs)[source]#

Transpiles the QuantumCircuit in the sense that there are no longer any synthesized gate objects. Furthermore, we can call the Qiskit transpiler by supplying keyword arguments.

The Qiskit transpiler is not called, if no keyword arguments are given.

Parameters:
**qiskit_kwargs

Keyword arguments for the Qiskit transpiler.

Returns:
QuantumCircuit

The transpiled QuantumCircuit.

Examples

We create a QuantumCircuit and append a synthesized gate. Afterwards we transpile to a given set of basis gates using the Qiskit transpiler:

>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(3)
>>> qc.mcx([0,1], 2)
>>> print(qc)
qb_0: ──■──
        │
qb_1: ──■──
      ┌─┴─┐
qb_2: ┤ X ├
      └───┘
>>> print(qc.transpile(basis_gates = ["cx", "rz", "sx"]))
global phase: 9π/8
      ┌──────────┐                 ┌───┐┌─────────┐   ┌───┐   ┌──────────┐┌───┐»
qb_1: ┤ Rz(-π/4) ├─────────────────┤ X ├┤ Rz(π/4) ├───┤ X ├───┤ Rz(-π/4) ├┤ X ├»
      ├──────────┤                 └─┬─┘└─────────┘   └─┬─┘   └──────────┘└─┬─┘»
qb_2: ┤ Rz(-π/4) ├───────────────────┼───────■──────────■──────────■────────┼──»
      ├─────────┬┘┌────┐┌─────────┐  │     ┌─┴─┐   ┌─────────┐   ┌─┴─┐      │  »
qb_3: ┤ Rz(π/2) ├─┤ √X ├┤ Rz(π/2) ├──■─────┤ X ├───┤ Rz(π/4) ├───┤ X ├──────■──»
      └─────────┘ └────┘└─────────┘        └───┘   └─────────┘   └───┘         »
«      ┌─────────┐┌───┐
«qb_1: ┤ Rz(π/4) ├┤ X ├────────────
«      └─────────┘└─┬─┘
«qb_2: ─────────────■──────────────
«      ┌─────────┐┌────┐┌─────────┐
«qb_3: ┤ Rz(π/4) ├┤ √X ├┤ Rz(π/2) ├
«      └─────────┘└────┘└─────────┘